package cn.tedu.websocket.demo.controller;

import cn.tedu.websocket.demo.server.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SendController {

    @Autowired
    private WebSocketServer webSocketServer;

    @GetMapping("/send/{userId}/{msg}")
    public String send(@PathVariable("userId") Integer userId,
                       @PathVariable("msg") String message) {
        webSocketServer.sendMsg2User(userId, message);
        return "ok";
    }
}
